<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()

const features = ref([
  {
    title: '智能对话',
    description: '基于百度千帆大模型的智能对话系统，可以回答各种问题，提供专业建议。',
    icon: 'ChatLineRound',
  },
  {
    title: '多模型支持',
    description: '支持多种大语言模型，包括ERNIE-Bot、ERNIE-Bot-turbo等，满足不同场景需求。',
    icon: 'SetUp',
  },
  {
    title: '高效响应',
    description: '快速响应用户输入，提供流畅的对话体验，让AI助手更贴近真实对话。',
    icon: 'Lightning',
  },
  {
    title: '安全可靠',
    description: '基于百度千帆平台的安全机制，保障用户数据安全和内容合规。',
    icon: 'Lock',
  },
])

const navigateToChat = () => {
  router.push('/chat')
}
</script>

<template>
  <main>
    <section class="hero">
      <div class="hero-content">
        <h1>欢迎使用七鱼AI助手</h1>
        <p class="subtitle">基于百度千帆大模型平台，为您提供智能、高效的AI对话服务</p>
        <el-button type="primary" size="large" @click="navigateToChat">
          开始对话 <el-icon class="el-icon--right"><ArrowRight /></el-icon>
        </el-button>
      </div>
      <div class="hero-image">
        <img src="@/assets/logo.svg" alt="AI助手" />
      </div>
    </section>

    <section class="features">
      <h2>核心功能</h2>
      <div class="feature-grid">
        <el-card v-for="(feature, index) in features" :key="index" class="feature-card">
          <div class="feature-icon">
            <el-icon :size="40"><component :is="feature.icon" /></el-icon>
          </div>
          <h3>{{ feature.title }}</h3>
          <p>{{ feature.description }}</p>
        </el-card>
      </div>
    </section>

    <section class="cta">
      <h2>立即体验AI的强大能力</h2>
      <p>无论是日常问答、知识咨询还是创意写作，七鱼AI助手都能满足您的需求</p>
      <el-button type="primary" size="large" @click="navigateToChat"> 开始对话 </el-button>
    </section>
  </main>
</template>

<style scoped>
main {
  width: 100%;
  margin: 0;
  padding: 20px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 60px 0;
  gap: 40px;
}

.hero-content {
  flex: 1;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 20px;
  color: #303133;
}

.subtitle {
  font-size: 1.2rem;
  color: #606266;
  margin-bottom: 30px;
  line-height: 1.6;
}

.hero-image {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero-image img {
  max-width: 100%;
  height: auto;
  max-height: 300px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-10px);
  }
  100% {
    transform: translateY(0px);
  }
}

.features {
  padding: 60px 0;
}

.features h2 {
  text-align: center;
  margin-bottom: 40px;
  font-size: 2rem;
  color: #303133;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 30px;
}

.feature-card {
  height: 100%;
  transition:
    transform 0.3s ease,
    box-shadow 0.3s ease;
}

.feature-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.feature-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  color: #409eff;
}

.feature-card h3 {
  text-align: center;
  margin-bottom: 15px;
  color: #303133;
}

.feature-card p {
  color: #606266;
  line-height: 1.6;
}

.cta {
  text-align: center;
  padding: 80px 0;
  background-color: #ecf5ff;
  border-radius: 8px;
  margin: 40px 0;
}

.cta h2 {
  font-size: 2rem;
  margin-bottom: 20px;
  color: #303133;
}

.cta p {
  font-size: 1.1rem;
  color: #606266;
  margin-bottom: 30px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .hero {
    flex-direction: column;
    text-align: center;
    padding: 40px 0;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }

  .cta {
    padding: 40px 20px;
  }
}
</style>
